//Parser object that contains all parser for all skins
//Parser = function Parser() {}; //No need to initialize

/**
 * @function namespace/signatrue - Component type : Control type : Parser.formskin : Parser.impl : html
 * conf - configuration properties for layout
 * prop - properties
 * parentconf - parent element conf
 * parentprop - parent element prop
 */
/*Parser["control:p:default:Json2htmlParser:html"] = function(conf, prop, parentconf, parentprop) {
	Parser.log(JSON.stringify(parentconf));
	Parser.log(JSON.stringify(parentprop));
	return '<span class="label"'+
			(prop["i18ntip-"+Parser.lang] ? (' original-title="'+prop["i18ntip-"+Parser.lang]+'"') : '') +
			'>'+
			prop["i18nname-"+Parser.lang]+'</span>'+
			'<span class="item"><span class="readonly" id="'+conf.id+'"' +
			'>{{b.'+prop.databinding+'}}</span>'+
			'<input type="hidden" name="'+conf.id+'"'+
			' desc="'+ prop["i18nname-" + Parser.lang]+'"' +
			' databinding="'+ prop.databinding+ '"'+
			(prop.processbinding ? (' binding="'+ prop.processbinding+'"'):'')+
			' ng-model="b.'+prop.databinding+'"' +
			' ng-bind="b.'+prop.databinding+'"' +
			'/></span>';
};*/

/**
 * @function namespace/signatrue - Component type : Control type : Parser.formskin : Parser.impl
 * conf - configuration properties for layout
 * prop - properties
 * parentconf - parent element conf
 * parentprop - parent element prop
 */
/*Parser["control:p:bootstrap-blue:Json2htmlParser:html"] = function(conf, prop, parentconf, parentprop) {
	Parser.log(JSON.stringify(parentconf));
	Parser.log(JSON.stringify(parentprop));
	var fmdcols = parseInt(parentconf.fmdcols);
	var cols = [1,fmdcols-1];
	if(fmdcols>3) {
		cols = [2,fmdcols-2];
	}
	return '<div class="col-md-'+cols[0]+'">'+
		    '<p'+
		    (prop["i18ntip-"+Parser.lang] ? (' original-title="'+prop["i18ntip-"+Parser.lang]+'"') : '') +
		    '>'+prop["i18nname-"+Parser.lang]+
		    '</p>'+
		    '</div>'+
		    '<div class="col-md-'+cols[1]+'">'+
		    '<span class="form-output" id="'+conf.id+'"' +
			'>{{b.'+prop.databinding+'}}</span>'+
			'<input type="hidden" name="'+conf.id+'"'+
			' desc="'+ prop["i18nname-" + Parser.lang]+'"' +
			' databinding="'+ prop.databinding+ '"'+
			(prop.processbinding ? (' binding="'+ prop.processbinding+'"'):'')+
			' ng-model="b.'+prop.databinding+'"' +
			' ng-bind="b.'+prop.databinding+'"' +
			'/>'+
			'</div>';
};*/

Parser["control:p:default:Json2htmlParser:html"] = function(confs) {
	var s = "";
	for (var c in confs) {
		var conf = confs[c];
		var prop = conf.id ? Parser.props[conf.id] : {};
		Parser.log(JSON.stringify(conf));
		Parser.log(JSON.stringify(prop));
		Parser.parseI18ntip(conf.id);
		var data = {};
		data.style = Parser.cssDisplay(prop.display)+(prop.style?prop.style:"");
		var fmdcols = parseInt(conf.fmdcols);
		Parser.log("input fmdcols="+fmdcols);
		var cols = [1,fmdcols-1];
		if(fmdcols>3) {
			cols = [2,fmdcols-2];
		}
		var transform = {"tag":"i"};
		transform.html = '<span class="label label1 col-md-'+cols[0]+'" '+(data.style ? ' style="'+data.style+'"' : '')+'>'+
			'<p'+
		    (prop["i18ntip-"+Parser.lang] ? (' title="'+prop["i18ntip-"+Parser.lang]+'"') : '') +
		    (prop.hideLabel=='1' ? ' style="display:none;"' : '')+
		    '>'+prop["i18nname-"+Parser.lang]+
		    (prop["i18ntip-"+Parser.lang] ? ('&nbsp;<i class="glyphicon glyphicon-question-sign"></i>') : '')+
		    '</p>'+
			'</span>'+
			'<span class="item item1 cellborder col-md-'+cols[1]+'" '+(data.style ? ' style="'+data.style+'"' : '')+'><span class="form-control readonly ng-cloak1 '+
			(prop.classNames ? prop.classNames : '')+'" id="'+conf.id+'"' + (data.style ? ' style="'+data.style+'"' : '')+
			'>{{b.'+prop.databinding+'}}</span>'+
			'<input type="hidden" name="'+conf.id+'"'+
			' desc="'+ prop["i18nname-" + Parser.lang]+'"' +
			' databinding="'+ prop.databinding+ '"'+
			//(prop.processbinding ? (' binding="'+ prop.processbinding+'"'):'')+
			' ng-model="b.'+prop.databinding+'"' +
			' ng-bind="b.'+prop.databinding+'"' +
			'/></span>';
		var wrapper = json2html.transform(data, transform);
		s += wrapper.substr(0, wrapper.length-4).substr(3);
	}
	return s;
};

Parser["control:p:bootstrap-blue:Json2htmlParser:html"] = function(confs) {
	var s = "";
	for (var c in confs) {
		var conf = confs[c];
		var prop = conf.id ? Parser.props[conf.id] : {};
		Parser.log(JSON.stringify(conf));
		Parser.log(JSON.stringify(prop));
		Parser.parseI18ntip(conf.id);
		var data = {};
		data.style = Parser.cssDisplay(prop.display)+(prop.style?prop.style:"");
		var transform = {"tag":"i"};
		var fmdcols = parseInt(conf.fmdcols);
		var cols = [1,fmdcols-1];
		if(fmdcols>3) {
			cols = [2,fmdcols-2];
		}
		transform.html = '<div class="col-md-'+cols[0]+'">'+
			    '<p'+
			    (prop["i18ntip-"+Parser.lang] ? (' title="'+prop["i18ntip-"+Parser.lang]+'"') : '') +
			    (prop.hideLabel=='1' ? ' style="display:none;"' : '')+
			    '>'+prop["i18nname-"+Parser.lang]+
			    (prop["i18ntip-"+Parser.lang] ? ('&nbsp;<i class="glyphicon glyphicon-question-sign"></i>') : '')+
			    '</p>'+
			    '</div>'+
			    '<div class="col-md-'+cols[1]+'">'+
			    '<span class="form-output '+(prop.classNames ? prop.classNames : '')+'"' + 
			    (data.style ? ' style="'+data.style+'"' : '')+
				'><span class="ng-cloak1" id="'+conf.id+'">{{b.'+prop.databinding+'}}</span>'+
				'<input type="hidden" name="'+conf.id+'"'+
				' desc="'+ prop["i18nname-" + Parser.lang]+'"' +
				' databinding="'+ prop.databinding+ '"'+
				//(prop.processbinding ? (' binding="'+ prop.processbinding+'"'):'')+
				' ng-model="b.'+prop.databinding+'"' +
				' ng-bind="b.'+prop.databinding+'"' +
				'/>'+
				'</span></div>';
		var wrapper = json2html.transform(data, transform);
		s += wrapper.substr(0, wrapper.length-4).substr(3);
	}
	return s;
};

